﻿using Microsoft.SharePoint;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindStyle.SPEntity.Converters
{
    public class DoubleConverter : IValueConverter
    {
        public object ToFieldValue(object value, Type targetType, ConversionContext context)
        {
            return System.Convert.ToDouble(value);
        }

        public object ToPropertyValue(object value, Type targetType, ConversionContext context)
        {
            if (targetType == typeof(int))
                return System.Convert.ToInt32(value);
            else if(targetType == typeof(decimal))
                return System.Convert.ToDecimal(value);
            else
                return value;
        }
    }
}
